var DEBUG=false;
var Log=function(textLog){
  if(DEBUG)console.log(textLog);
}

Utils=function(){
  var self=this;

  self.colors={};
  //extracts the maxium of an array arr using the comparer cmp
  self.max=function(arr,cmp){
    if(cmp==undefined)
      cmp=function(a,b){return a-b};
    //Log('cmp:');
    //Log(cmp);
    maxValue=arr[0];
    for(var i=1;i<arr.length;i++)
      if(cmp(maxValue,arr[i])<0)
        maxValue=arr[i];
    return maxValue;
  }
  self.getColor=function(action){
    if(action in self.colors)
      return self.colors[action];
    else{
      var r1=Math.floor(Math.random()*256);
      var r2=Math.floor(Math.random()*256);
      var r3=Math.floor(Math.random()*256);
      self.colors[action]='rgb('+r1+','+r2+','+r3+')';
      return self.colors[action];
    }
  }
  self.resetColors=function(){
    self.colors={};
    return self;
  }
}

utils=new Utils();
